﻿@{
    ViewBag.Title = "用户权限";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<script src="~/Assets/global/Plugins/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="@Url.Content("~/Scripts/My97DatePicker/WdatePicker.js")"></script>
@using Webdiyer.WebControls.Mvc;
@using DoKnow.CloudEdu.CMS.Host.Models;
@using DoKnow.CloudEdu.Common.Enums;
@model Webdiyer.WebControls.Mvc.PagedList<BSUserPageInfo>
<!-- BEGIN PAGE HEADER-->
@Html.Partial("_PageHeader", new PageHeader() { Title = "用户权限", Urls = new Dictionary<string, string>() { { "权限管理", "/Authority/Index" }, { "用户权限", "#" } } })
<!-- END PAGE HEADER -->
<div>
    @using (Html.BeginForm("QueryBsUser", "Authority", new RouteValueDictionary { { "pageIndex", "" } }, FormMethod.Get))
    {

        <div id="searchContatiner" action="#" class="form-horizontal">
            <div class="form-body">
                <div class="row">
                    <div class="col-md-3">
                        <div class="form-group">
                            <label class="control-label col-md-3">角色</label>
                            <div class="col-md-8">
                                <input type="text" name="roleName" class="form-control input-small" value="@Request.QueryString["DispRoleName"]" readonly="readonly">
                                <input type="hidden" name="roleId" value="@ViewBag.RoleId" />
                                <span class="help-block">
                                </span>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-4">
                        <div class="form-group">
                            <label class="control-label col-md-3">用户编码</label>
                            <div class="col-md-8">
                                <input type="text" name="code" class="form-control input-small" value="@Request.QueryString["code"]" id="code">
                                <span class="help-block">
                                </span>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-4">
                        <div class="form-group">
                            <label class="control-label col-md-3">真实姓名</label>
                            <div class="col-md-8">
                                <input type="text" name="RealName" class="form-control input-small" value="@Request.QueryString["RealName"]" id="txtRealName">
                                <span class="help-block">
                                </span>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-3">
                        <button type="submit" class="btn green">查询</button>
                        <button type="reset" class="btn default">清除</button>
                    </div>
                </div>
            </div>
        </div>

    }
</div>
<form id="user" action="@Url.Action("RemoveUsersUnderRole")">
    <input type="hidden" name="roleId" value="@ViewBag.RoleId" />
    <input type="hidden" name="roleName" value="@ViewBag.RoleName" />
    <div class="portlet box purple">
        <div class="portlet-title">
            <div class="actions">
                <a href="@Url.Action("AddUsers", "Authority", new { RoleId = @ViewBag.RoleId, RoleName = @ViewBag.RoleName })" class="btn green"><i class="fa fa-plus"></i>添加</a>
                <button type="submit" id="btnRemove" class="red btn" value=""><i class="fa fa-trash-o"></i>移除</button>
                <a href="@Url.Action("Index", new {RoleCode = Request.QueryString["RoleCode"], RoleName = @Request.QueryString["RoleName"] })" class="btn green"><i class="fa fa-reply"></i>返回</a>
            </div>
        </div>
        <div style="background-color: #ffffff; border: 1px solid #eaeaea; border-radius: 5px; line-height: 24px; padding: 8px; position: relative; font-size: 14px; overflow-x: auto;">
            <table class="table table-striped table-hover table-bordered" style=" max-width: 1600px;">
                <thead>
                    <tr>
                        <th>操作</th>
                        <th>用户编号</th>
                        <th>实名</th>
                        <th>昵称</th>
                        <th>手机号</th>
                        <th>用户类型</th>
                        <th>状态</th>
                        <th>创建时间</th>
                        <th>最后修改时间</th>
                    </tr>
                </thead>
                <tbody>
                    @if (Model != null)
                    {
                        foreach (var item in Model)
                        {
                            <tr>
                                <td style="width: 100px;">
                                    <input type="checkbox" name="selectedUsers" value="@item.ID" class="form-control">
                                </td>
                                <td>@item.Code</td>
                                <td>@item.RealName</td>
                                <td>@item.NickName</td>
                                <td>@item.Mobile</td>
                                <td>@EnumHelper.GetDescription(typeof(EnumHelper.UserCategory), item.Category)</td>
                                <td>@EnumHelper.GetDescription(typeof(EnumHelper.CommonStatus), item.Status)</td>
                                <td>
                                    @if (item.CreateTime.ToString("yyyy-MM-dd") != "1990-01-01")
                                    { @item.CreateTime.ToString()}
                                </td>
                                <td>
                                    @if (item.ModifyTime.ToString("yyyy-MM-dd") != "1990-01-01")
                                    { @item.ModifyTime.ToString("")}
                                </td>
                            </tr>
                        }
                        <tr>
                            <td colspan="14" class="pager-footer">
                                @Html.Pager(Model, new PagerOptions
                       {
                           PageIndexParameterName = "PageIndex",
                           ShowPageIndexBox = false,
                           FirstPageText = "首页",
                           PrevPageText = "上一页",
                           NextPageText = "下一页",
                           LastPageText = "末页",
                           ShowGoButton = false,

                       })
                                <div style="float: right;">
                                    共 @Model.TotalPageCount 页 @Model.TotalItemCount 条记录，当前为第 @Model.CurrentPageIndex 页
                                </div>
                            </td>
                        </tr>
                    }
                    else
                    {
                        <tr>
                            <td colspan="14">@ViewBag.Msg</td>
                        </tr>
                    }
                </tbody>
            </table>
        </div>
    </div>
</form>
<style type="text/css">
    .ProduceTab {
        width: 100%;
        background: none repeat scroll 0 0 #F2F2F2;
    }

        .ProduceTab input {
            width: 130px;
        }
</style>
<script type="text/javascript">
    function GetDateDiff(startDate, endDate) {
        var startTime = new Date(Date.parse(startDate.replace(/-/g, "/"))).getTime();
        var endTime = new Date(Date.parse(endDate.replace(/-/g, "/"))).getTime();
        var dates = Math.abs((startTime - endTime)) / (1000 * 60 * 60 * 24);
        return dates;
    }
    function CliExport() {
        if ($("#ORDER_BEGIN_TIME").val() == "" || $("#ORDER_END_TIME").val() == "") {
            alert("请选择创建订单时间！"); return false;
        }
        else {
            var startDate = $("#ORDER_BEGIN_TIME").val();
            var endDate = $("#ORDER_END_TIME").val();
            var days = GetDateDiff(startDate, endDate);
            if (days > 7) {
                alert("单次查询最大时间跨度为7天！");
                return false;
            }
        }
        var QueryProduce = {};
        QueryProduce["ORDER_CODE"] = $("#ORDER_CODE").val();//订单号
        QueryProduce["STATUS"] = $("#status").val() == "" ? "0" : $("#STATUS").val();//生产单状态
        QueryProduce["ORDER_BEGIN_TIME"] = $("#ORDER_BEGIN_TIME").val();//打版开始时间
        QueryProduce["ORDER_END_TIME"] = $("#ORDER_END_TIME").val();//打版结束时间
        var link = "/PreProduce/Export?QueryProduce=" + JSON.stringify(QueryProduce);
        window.open(link);
    }
</script>


